require.config({
  baseUrl: 'js',
  shim: {
    backbone: {
      deps: ['underscore', 'jquery']
    }
  },
  paths: {
    moment: 'lib/moment.min',
    wx: 'lib/jweixin-1.0.0',
    jquery: 'lib/jquery-1.8.3.min',
    backbone: 'lib/backbone-min',
    underscore: 'lib/underscore-min',
    vue: 'lib/vue/vue.min',
    // Require.js plugins
    text: 'lib/require/text',
    // Just a short cut so we can put our html outside the js dir
    // When you have HTML/CSS designers this aids in keeping them out of the js directory
    tmpl: '../tmpl',
    util: 'ext/util',
    service: 'ext/service',
    vm: 'ext/vm',
    event: 'ext/event'
  }
});

require([
  'jquery',
  'vue',
  'service',
  'underscore',
  'util',
  'vm',
  'ext/alert',
  'event'
], function($, Vue, service, _,util, Vm, Alert, Event) {

  var view = Vm.create(this, 'AlertModule', Alert);
  view.render();

  window.view = new Vue({
    el: '#container',
    ready: function() {
      var self = this;
      service('/hy5b/auto/json.json')
        .on('querySuccess', function(data) {
          $.each(data.data, function(i, val) {
            self.items.push(val);
          });
          Event.trigger('ready');
        })
        .query({pageNum:1, pageSize:100});
    },
    data: {
      items: []
    },
    methods: {
      showAlert: function(index) {
        view.trigger('showAlert', this.items[index].name);
      },
      test: function(src) {
        var self = this;
        $.each([{name:'aaa'}, {name:'bbb'}], (function(i, val) {
          self.items.push(val);
        }));
      }
    }
  });
});

require(['transition']);